# -*- coding: utf-8 -*-
# @Time : 2021/10/24 16:13
# @Author : 唐宁
# @Site : 
# @File : zhihu_spider.py
# @Software: PyCharm
import click as click
import scrapy
from selenium import webdriver
import time


class ZhiHuSpider(scrapy.Spider):
    name = 'zhihu_spider'
    allowed_domains = ['www.zhihu.com']
    start_urls = ['https://www.zhihu.com']

    def start_requests(self):
        browser = webdriver.Chrome(executable_path="D:/ubuntu/cnblogs/driver/chromedriver.exe")
        # 调用登录
        browser.get("https://www.zhihu.com/signin")
        browser.find_element_by_xpath("/html/body/div[1]/div/main/div/div/div/div[1]/div/div[1]/form/div[2]/div[2]/label/input").send_keys("15953570135")
        # 点击获取验证码
        browser.find_element_by_xpath("/html/body/div[1]/div/main/div/div/div/div[1]/div/div[1]/form/div[3]/button").click()
        time.sleep(60)
        browser.find_element_by_xpath("/html/body/div[1]/div/main/div/div/div/div[1]/div/div[1]/form/div[3]/div/label/input").send_keys("123552")
        browser.find_element_by_xpath("/html/body/div[1]/div/main/div/div/div/div[1]/div/div[1]/form/button").click()

        time.sleep(60)

    def parse(self, response):
        pass
